<template>
	<view class="flex-col justify-start relative page">
		<view class="flex-col section space-y-60">
			<view class="flex-row justify-center relative">
				<image class="image pos" @click="backpage"
					src="https://gongxiangtaiqiu.axa2.com/taiqiu/16777480137488403283.png" />
				<text class="text">卡券列表</text>
			</view>
			<u-select v-model="shopshow" :list="shopList" @confirm="confirm"></u-select>
			<!-- <view class="flex-row justify-between items-center group">
				<text class="text_2">{{shop_name?shop_name:'请选择店铺'}}</text>
				<view class="flex-row space-x-7">
					<text class="font_1 text_3" @click="shopshow = true">切换门店</text>
					<image class="shrink-0 image_2"
						src="https://gongxiangtaiqiu.axa2.com/taiqiu/16777400650594751651.png" />
				</view>
			</view> -->
			<view
				style="width: 360px;height: 60px;background-color: #19c865; border-radius: 13px 13px 0 0; margin-left: 4px;">
				<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" inactive-color="#369861"
					active-color="#5FFF95" :active-item-style="activeItemStyle" :bar-style="barStyle"
					:inactive-item-style="inactiveItemStyle"></u-tabs>
			</view>
		</view>

		<!-- <view v-if="vipcard==1"> -->
		<view class="flex-col group_2 space-y-60 pos_4" v-if="current==0">
			<view class="flex-col section_3">
				<view class="items" v-for="(item,index) in cardList" :key="index" :data-index="index">
					<delSlideLeft :item="item" :data_transit="{index :index , item:item }" @delItem="delItem" :status="current">
						<view class="editItem">
							<view>
								<!-- <image src="https://gongxiangtaiqiu.axa2.com/taiqiu/vvvvvip.png"
									style="width: 100%; height: 100%;">
								</image> -->
								
								<view class="left-img">
									<image src="https://gongxiangtaiqiu.axa2.com/taiqiu/putongvip.png"
										style="width: 100%; height: 100%;"></image>
								</view>
								<view
									style="display: flex; justify-content: center; height: 45px; position: absolute; top: 20px;  left: 50px;">
									<view class="vip">{{item.f_card_name}}</view>
									<view class="card1">（{{item.f_discount}}）</view>
								</view>
								<view class="card" style="position: absolute; left: 20px; top: 73px;">
									充值金额：{{item.f_condition}}元
								</view>
								<!-- <view class="card" style="position: absolute; left: 150px; top: 73px;">赠送金额：{{item.f_intro}}元</view> -->
								<view class="card" style="position: absolute; left: 20px; top: 100px;">
									卡券说明：{{item.f_intro}}
								</view>
							</view>
						</view>
					</delSlideLeft>
				</view>
			</view>
		</view>

		<view class="flex-col group_2 space-y-51 pos_4" v-if="current==1">
			<view class="flex-col section_3">
				<view class="item"	v-for="(currenitem,currenindex) in CouponList" :key="currenindex" :data-index="currenindex">
					<delSlideLeft :item="currenitem" :data_transit="{index :index , item:currenitem }" @delItem="delCurrenitem" :status="current">
					<view class="font">
						<image src="https://gongxiangtaiqiu.axa2.com/taiqiu/font.png" style="width: 100%; height: 100%;">
						</image>
					</view>
					<view class="cen">
						<view class="item-center">
							<view class="price">
								<view class="price-p">{{Math.trunc(currenitem.f_free_money)}}</view>
								<view class="black">
									<view class="black-p">元</view>
								</view>
							</view>
							<view class="time">
								<view class="" style="display: flex;">
									<view class="title">
										{{currenitem.f_name}}
									</view>
									<view class="full"
										:style="{backgroundImage: 'url('+image1+')',backgroundSize: '100% 100%'}">
										<view class="full-p">
											满{{Math.trunc(currenitem.f_condition_money)}}可用
										</view>
									</view>
								</view>
								<view class="time-start">
									有效期始：{{currenitem.f_start_date}}
								</view>
								<view class="time-end">
									有效期始：{{currenitem.f_end_date}}
								</view>
							</view>
						</view>
						<!-- <view class="user">
							<view class="user-p">
								立即使用
							</view>
						</view> -->
					</view>
				</delSlideLeft>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import delSlideLeft from '@/components/ay-operate/del_slideLeft.vue'
	export default {
		components: {
			delSlideLeft
		},
		data() {
			return {
				image: 'https://gongxiangtaiqiu.axa2.com/taiqiu/coupons.png',
				image1: 'https://gongxiangtaiqiu.axa2.com/taiqiu/full.png',
				image2: 'https://gongxiangtaiqiu.axa2.com/taiqiu/full-gray.png',
				image3: 'https://gongxiangtaiqiu.axa2.com/taiqiu/coupons-gray.png',
				activeItemStyle: {
					color: '#19C865',
					background: '#ffffff',
					borderRadius: '13px 13px 0 0',
					maginLeft: '20px',
				},
				barStyle: {
					marginLeft: '-10px',
					width: '38px',
					height: '2px',
					background: '#19C865',
				},
				inactiveItemStyle: {
					background: '#ffaa00',
				},
				// vipcard: 1,
				timevalue: '',
				discountvalue: '',
				value: '',
				type: 'select',
				show: false,
				shopshow: false,
				show1: false,
				border: true,
				actionSheetList: [{
						text: '男'
					},
					{
						text: '女'
					},
					{
						text: '保密'
					}
				],
				discountList: [{
						text: '3折'
					},
					{
						text: '9折'
					},
					{
						text: '1折'
					}
				],
				show: false,
				list: [{
					name: '会员卡列表'
				}, {
					name: '优惠券列表'
				}],
				cardList: {},
				shop_name: '',
				current: 0,
				shopList: {},
				CouponList: {},
				// 演示地址，请勿直接使用
				action: 'http://www.example.com/upload',
				fileList: [{
					url: 'http://pics.sc.chinaz.com/files/pic/pic9/201912/hpic1886.jpg',
				}]
			};
		},
		onLoad() {
			if (uni.getStorageSync('Bshop_name') == '') {
				uni.showToast({
					icon: 'none',
					title: '请在首页选择店铺哦！'
				})
				setTimeout(() => {
					uni.navigateBack({
						delta: 1
					})
				}, 2000)
			}
			this.shop()
			this.vipList()
			this.Coupons()
		},
		
		methods: {
			
			//点击删除按钮事件
			delItem(e) {
				let that = this;
				this.$Api.delMemberCard({
					id: e.item.id,
				}).then(res => {
					console.log(res.data.code)
					if(res.data.code == 1){
						uni.showToast({
							icon:'none',
							title:res.data.data
						})
						return
					}
					if (res.data.code == 0){
						uni.showToast({
							icon:'success',
							title:'删除成功'
						})
						that.cardList.splice(e.data.index,1)
						this.vipList()
					}
				});
			},
			//删除优惠券
			delCurrenitem(e){
				let that = this;
				this.$Api.delCoupon({
					id: e.item.id,
				}).then(res => {
					if (res.data.code == 0){
						uni.showToast({
							icon:'success',
							title:'删除成功'
						})
						that.CouponList.splice(e.data.index,1)
						this.Coupons()
					}
					if(res.data.code == 1){
						uni.showToast({
							icon:'none',
							title:res.data.data
						})
						return
					}
				});
			},
			//商家的优惠券
			Coupons() {
				this.$Api.shopCoupons({
					shopId: uni.getStorageSync('Bshop_id'),
				}).then(res => {
					this.CouponList = res.data.data
					console.log(res.data.data, 'cardList')
				});

			},
			//会员卡列表
			vipList() {
				this.$Api.getMemberCard({
					shopId: uni.getStorageSync('Bshop_id'),
				}).then(res => {
					this.cardList = res.data.data
					console.log(res.data.data, 'cardList')
				});
			},
			// 商家店铺列表
			shop() {
				this.$Api.getMyShop({
					userId: uni.getStorageSync('userid'),
				}).then(res => {
					console.log(res.data.data, '12121212')
					let arr = res.data.data
					this.shopList = arr.map(item => {
						return {
							label: item.f_shop_name,
							value: item.id
						}
					})
					console.log(this.shopList)
				});
			},
			//店铺选择
			confirm(e) {
				this.shop_name = e[0].label
				this.shop_id = e[0].value
				uni.setStorageSync('shop_id', this.shop_id);
				uni.setStorageSync('shop_name', this.shop_name);
				console.log(this.shop_id, this.shop_name);
			},
			change(index) {
				this.current = index;
				console.log(this.current)
			},
			backpage() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 点击actionSheet回调
			actionSheetCallback(index) {
				this.value = this.actionSheetList[index].text;
			},
			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				// console.log(e);
			},
			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				// console.log(e);
			},
			submit() {
				this.$refs.uUpload.upload();
			},
			discountCallback(index) {
				this.discountvalue = this.discountList[index].text;
			},
			timeCallback(index) {
				this.timevalue = this.timeList[index].text;
			},
			// changecode() {
			// 	this.vipcard = 1
			// 	console.log('0000000000000000000000', this.vipcard)
			// },
			// juan() {
			// 	this.vipcard = 0
			// 	console.log('0000000000000000000000', this.vipcard)
			// }

		},
	};
</script>

<style lang="scss">
	.items {
		width: 665rpx;
		height: 266rpx;
		margin: auto;
		margin-top: 30rpx;
		// position: relative;

		.card {
			// width: 85px;
			height: 22px;
			font-size: 12px;
			font-family: PingFang SC;
			color: #ffc9a7;
			position: absolute;
			top: 45px;
			left: 170px;

		}

		.card1 {
			// width: 85px;
			height: 22px;
			font-size: 12px;
			font-family: PingFang SC;
			color: #ffc9a7;
			line-height: 65px;
			// position: absolute;
			// top: 45px;
			// left: 170px;

		}

		.left-img {
			width: 20px;
			height: 17px;
			position: absolute;
			top: 33px;
			left: 25px;
		}

		.vip {
			// width: 172px;
			height: 42px;
			font-size: 28px;
			font-family: MiSans;
			font-weight: 800;
			font-style: italic;
			color: #ffc9a7;
			line-height: 48px;
			// position: absolute;
			
			// top: 20px;
			// left: 55px;
		}
	}

	.item {
		width: 660rpx;
		height: 279rpx;
		// background-image: url('https://gongxiangtaiqiu.axa2.com/taiqiu/coupons.png');
		// z-index: 99999;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		margin: auto;
		margin-top: 40rpx;
		// padding-top: 20rpx;

		.font {
			width: 132rpx;
			height: 26rpx;
			margin-left: 40rpx;
		}

		.cen {
			width: 640rpx;
			height: 249rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.item-center {
				width: 620rpx;
				height: 192rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				// margin-left: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.time {
					height: 150rpx;
					margin-left: 20rpx;

					.time-start {
						// width: 239rpx;
						height: 23rpx;
						font-size: 22rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						margin-top: 20rpx;
					}

					.time-end {
						// width: 239rpx;
						height: 23rpx;
						font-size: 22rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #666666;
						margin-top: 20rpx;
					}

					.title {
						width: 182rpx;
						height: 35rpx;
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #222222;
					}

					.full {
						width: 144rpx;
						height: 32rpx;
						margin-top: 10rpx;

						.full-p {
							font-size: 22rpx;
							font-family: PingFang SC;
							font-weight: 500;
							color: #222222;
							display: flex;
							justify-content: center;
							align-items: center;
						}
					}
				}

				.price {
					width: 220rpx;
					height: 150rpx;
					background: #8CFF80;
					border-radius: 8rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					// margin-left: 20rpx;

					.black {
						width: 36rpx;
						height: 36rpx;
						background: #222222;
						border-radius: 50%;
						margin-top: 20px;
						display: flex;
						justify-content: center;
						align-items: center;

						.black-p {
							font-size: 22rpx;
							font-family: PingFang SC;
							font-weight: bold;
							color: #FFFFFF;

						}
					}


					.price-p {
						width: 130rpx;
						font-size: 90rpx;
						font-family: PingFang SC;
						font-weight: 800;
						font-style: italic;
						color: #222222;
					}
				}
			}

			.user {
				width: 72rpx;
				height: 192rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.user-p {
					width: 29rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #222222;
				}
			}
		}

	}

	html {
		font-size: 16px;
	}

	body {
		margin: 0;
		font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
			'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	view,
	image,
	text {
		box-sizing: border-box;
		flex-shrink: 0;
	}

	#app {
		width: 100vw;
		height: 100vh;
	}

	.flex-row {
		display: flex;
		flex-direction: row;
	}

	.flex-col {
		display: flex;
		flex-direction: column;
	}

	.justify-start {
		justify-content: flex-start;
	}

	.justify-end {
		justify-content: flex-end;
	}

	/deep/ .u-list-item {
		width: 160rpx !important;
		height: 160rpx !important;
		background: #ffffff !important;
		border: dashed 2rpx #19c865 !important;

	}

	/deep/ .u-scroll-box {
		background: #93E6B7 !important;
		border-radius: 13px 13px 0 0 !important;
	}

	.justify-center {
		justify-content: center;
	}

	.justify-between {
		justify-content: space-between;
	}

	.justify-around {
		justify-content: space-around;
	}

	.justify-evenly {
		justify-content: space-evenly;
	}

	.items-start {
		align-items: flex-start;
	}

	.items-end {
		align-items: flex-end;
	}

	.items-center {
		align-items: center;
	}

	.items-baseline {
		align-items: baseline;
	}

	.items-stretch {
		align-items: stretch;
	}

	.self-start {
		align-self: flex-start;
	}

	.self-end {
		align-self: flex-end;
	}

	.self-center {
		align-self: center;
	}

	.self-baseline {
		align-self: baseline;
	}

	.self-stretch {
		align-self: stretch;
	}

	.flex-1 {
		flex: 1 1 0%;
	}

	.flex-auto {
		flex: 1 1 auto;
	}

	.grow {
		flex-grow: 1;
	}

	.grow-0 {
		flex-grow: 0;
	}

	.shrink {
		flex-shrink: 1;
	}

	.shrink-0 {
		flex-shrink: 0;
	}

	.relative {
		position: relative;
	}

	.page {
		padding-bottom: 1272rpx;
		background-color: #f3f3f5;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.section {
		padding: 104rpx 23rpx 494rpx;
		background-image: linear-gradient(0deg, #f3f3f5 0%, #19c865 61%, #19c865 100%);
	}

	.image {
		width: 20rpx;
		height: 34rpx;
	}

	.pos {
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
	}

	.text {
		color: #ffffff;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 700;
		line-height: 34rpx;
	}

	.group {
		padding: 0 8rpx;
	}

	.text_2 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 700;
		line-height: 31rpx;
	}

	.font_1 {
		font-size: 24rpx;
		font-family: PingFang SC;
		line-height: 23rpx;
	}

	.text_3 {
		color: #ffffff;
		font-weight: 700;
	}

	.image_2 {
		width: 24rpx;
		height: 22rpx;
	}

	.group_2 {
		padding: 0 30rpx;
	}

	.space-y-60>view:not(:first-child),
	.space-y-60>text:not(:first-child),
	.space-y-60>image:not(:first-child) {
		margin-top: 60rpx;
	}

	.pos_4 {
		position: absolute;
		left: 0;
		right: 0;
		top: 264rpx;
	}




	/deep/ .u-tabs {
		background: #ffffff !important;
		width: 360px !important;
		height: 40px !important;
		border-radius: 13px 13px 0 0 !important;
	}

	/deep/ .u-tabs {
		background: rgba(25, 200, 101, 255) !important;
		border-radius: 13px 13px 0 0 !important;


	}

	.section_3 {
		// padding-left: 29rpx;
		// padding-top: 49rpx;
		height: auto;
		padding-bottom: 20px;
		background-color: #ffffff;
		/* border-radius: 24rpx; */
	}

	.group_3 {
		margin-top: 46rpx;
		padding: 0 8rpx 40rpx;
		border-bottom: solid 1rpx #eeeeee;
	}

	.view {
		margin-top: 0;
	}

	.font_5 {
		font-size: 28rpx;
		font-family: PingFang SC;
		line-height: 13rpx;
		font-weight: 500;
		color: #ffa229;
	}

	.font_3 {
		font-size: 28rpx;
		font-family: PingFang SC;
		line-height: 26rpx;
		font-weight: 500;
		color: #222222;
	}

	.font_4 {
		font-size: 28rpx;
		font-family: PingFang SC;
		line-height: 26rpx;
		font-weight: 500;
		color: #999999;
	}

	.text_6 {
		margin-right: 18rpx;
	}

	.group_4 {
		margin-right: 32rpx;
	}

	.image_3 {
		width: 24rpx;
		height: 14rpx;
	}

	.group_5 {
		padding: 44rpx 8rpx;
		border-bottom: solid 1rpx #eeeeee;
	}

	.group_6 {
		margin-right: 32rpx;
	}

	.space-x-15>view:not(:first-child),
	.space-x-15>text:not(:first-child),
	.space-x-15>image:not(:first-child) {
		margin-left: 15rpx;
	}

	.text_7 {
		margin-right: 18rpx;
	}



	.group_8 {
		padding: 46rpx 8rpx 42rpx;
		border-bottom: solid 1rpx #eeeeee;
	}

	.text_8 {
		margin-right: 18rpx;
	}

	.view_2 {
		margin-top: 36rpx;
	}

	.section_5 {
		margin-right: 22rpx;
		padding: 10rpx 9rpx 10rpx 13rpx;
		background-color: #ffffff;
		border-radius: 4rpx;
		height: 48rpx;
	}

	.space-x-7>view:not(:first-child),
	.space-x-7>text:not(:first-child),
	.space-x-7>image:not(:first-child) {
		margin-left: 7rpx;
	}

	.image_4 {
		width: 18rpx;
		height: 18rpx;
	}

	.text_9 {
		color: #19c865;
		font-weight: 500;
	}

	.image_5 {
		margin-right: 31rpx;
		margin-top: 29rpx;
		background-color: #f3f3f5;
		border-radius: 16rpx;
		width: 630rpx;
		height: 350rpx;
	}

	.group_9 {
		padding: 36rpx 0 39rpx;
	}

	.space-y-21>view:not(:first-child),
	.space-y-21>text:not(:first-child),
	.space-y-21>image:not(:first-child) {
		margin-top: 21rpx;
	}

	.text_10 {
		margin-left: 25rpx;
		line-height: 27rpx;
	}

	.text-wrapper_2 {
		margin-right: 31rpx;
		margin-top: 21rpx;
		padding: 29rpx 0 59rpx;
		background-color: #f3f3f5;
		border-radius: 16rpx;
		border: solid 1rpx #eeeeee;
	}

	.text_11 {
		margin-left: 33rpx;
		line-height: 27rpx;
	}

	.button {
		padding: 30rpx 0;
		background-color: #19c865;
		border-radius: 44rpx;
	}

	.font_2 {
		font-size: 30rpx;
		font-family: PingFang SC;
		line-height: 28rpx;
	}

	.text_12 {
		color: #ffffff;
		font-weight: 700;
	}

	.text-wrapper {
		padding: 27rpx 0 54rpx;
		background-color: #ffffff80;
		border-radius: 24rpx 24rpx 0px 0px;
		width: 340rpx;
	}

	.pos_3 {
		position: absolute;
		right: 32rpx;
		top: 283rpx;
	}

	.text_5 {
		color: #369861;
		font-weight: 500;
	}

	.section_2 {
		padding: 40rpx 0 2rpx;
		background-color: #ffffff;
		border-radius: 24rpx 24rpx 0px 0px;
		width: 340rpx;
	}

	.space-y-15>view:not(:first-child),
	.space-y-15>text:not(:first-child),
	.space-y-15>image:not(:first-child) {
		margin-top: 15rpx;
	}

	.pos_2 {
		position: absolute;
		left: 30rpx;
		top: 270rpx;
	}

	.text_4 {
		color: #19c865;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 700;
		line-height: 29rpx;
	}

	.section_4 {
		background-color: #19c865;
		border-radius: 2rpx;
		width: 40rpx;
		height: 4rpx;
	}
</style>
